﻿#pragma once
#include<iostream>
#define myapp Application::getInstance()
class GLFWwindow;

using ResizeCallBack = void (*)(int width, int height);
using KeyBoardCallBack = void (*)(int key, int action, int mods);
using MouseCallBack = void (*)(int button, int action, int mods);
using CursorCallBack = void(*)(double xpos, double ypos);
using ScrollCallBack = void (*)(double yoffset);
class Application
{
public:	
	void test();
	static Application* getInstance();
	~Application();

	uint32_t getWidth()const { return mWidth; }
	uint32_t getHeight()const{ return mHeight; }
	bool init(uint32_t width=800, uint32_t height=600);
	bool update();
	void destroy();
	void setResizeCallBack(ResizeCallBack callBack) { mResizeCallBack = callBack; }
	void setKeyBoardCallBack(KeyBoardCallBack callBack) { mKeyBoardCallBack = callBack; }
	void setMouseButtonCallBack(MouseCallBack callBack) { mMouseButtonCallBack = callBack; }
	void setCursorPosCallBack(CursorCallBack callBack) { mCursorPosCallBack = callBack; }
	void setScrollCallBack(ScrollCallBack callBack) { mScrollCallBack = callBack; }
	void getCursorPos(double* x, double* y);
private:
	static void frameBufferResizeCallBack(GLFWwindow* window,int width,int height);
	static void keyCallBack(GLFWwindow* window, int key, int scancode, int action, int mods);
	static void mouseButtonCallBack(GLFWwindow* window, int button, int action, int mods);
	static void cursorPosCallBack(GLFWwindow* window, double xpos, double ypos);
	static void scrollCallBack(GLFWwindow* window, double xoffset, double yoffset);
private:
	uint32_t mWidth{0};
	uint32_t mHeight{ 0 };
	GLFWwindow* mWindow{};
	static Application* inst;
	ResizeCallBack mResizeCallBack{};
	KeyBoardCallBack mKeyBoardCallBack{};
	MouseCallBack mMouseButtonCallBack{};
	CursorCallBack mCursorPosCallBack{};
	ScrollCallBack mScrollCallBack{};


	Application();
};

